function XULassociatedList(parentDOMObject, columnArray, id, onSelectHandler){
	this.setup(parentDOMObject, columnArray, id, onSelectHandler);
}

XULassociatedList.prototype.setup=function(parentDOMObject, columnArray, id, onSelectHandler){
	this.elementTree=document.createElement("tree");
	if(id!=undefined) this.elementTree.id=id;
	if(onSelectHandler!=undefined) this.elementTree.onselect=onSelectHandler;
	this.elementTree.setAttribute("flex","1");
	this.elementCols=document.createElement("treecols");
	
	this.elementTree.appendChild(this.elementCols);
	
	this.elementColsColumns=new Array();
	for(var i=0;i<columnArray.length;i++){
		this.elementColsColumns[i]=document.createElement("treecol");
		if(typeof(columnArray[i])=="String"){
			this.elementColsColumns[i].setAttribute("label",columnArray[i]);
			this.elementColsColumns[i].setAttribute("id",columnArray[i]);
			this.elementColsColumns[i].setAttribute("flex","1");
		}else{
			if(columnArray[i]["label"]!=undefined) this.elementColsColumns[i].setAttribute("label",columnArray[i]["label"]);
			if(columnArray[i]["id"]!=undefined) this.elementColsColumns[i].setAttribute("id",columnArray[i]["id"]);
			if(columnArray[i]["flex"]!=undefined) this.elementColsColumns[i].setAttribute("flex",columnArray[i]["flex"]);
		}
		this.elementCols.appendChild(this.elementColsColumns[i]);
	}
	parentDOMObject.appendChild(this.elementTree);
	
}

XULassociatedList.prototype.applyList=function(dataArray){
	this.clear();


	this.elementChildren=document.createElement("treechildren");
	this.elementItems=new Array();
	this.elementItemsRows=new Array();
	for(var i=0;i<dataArray.length;i++){
		this.elementItems[i]=document.createElement("treeitem");
		this.elementItemsRows[i]=document.createElement("treerow");
		this.elementItems[i].appendChild(this.elementItemsRows[i]);
		for(var j=0;j<dataArray[i].length;j++){
			var treecell=document.createElement("treecell");
			treecell.setAttribute("label",dataArray[i][j]);
			this.elementItemsRows[i].appendChild(treecell);
		}
		this.elementChildren.appendChild(this.elementItems[i]);
	}
	this.elementTree.appendChild(this.elementChildren);
}

XULassociatedList.prototype.clear=function(){
	if(this.elementChildren!=undefined) this.elementTree.removeChild(this.elementChildren);
}